//
//  STDShapenLayer.hpp
//  STDRenderSDK
//
//  Created by 陈学明 on 2023/3/15.
//

#ifndef STDShapenLayer_hpp
#define STDShapenLayer_hpp

#include <stdio.h>
#include "STDBaseLayer.hpp"
#include <Basic/Path/STDSPath.hpp>
#include <Effects/STDSShapenStrokeEffect.h>
#include <Effects/STDSShapenFillEffect.h>
/// 形状图层
class STDShapenLayer: public STDBaseLayer {
public:
    STDShapenLayer() {
        setType(STDLayerTypeShapen);
    }
    
    void draw() override {
        shared_ptr<STDSRenderTarget> inputFbo = drawShapen();
        for (auto effect: effects) {
            if (effect->isVisible() == false) {
                continue;
            }
            auto fbo = make_shared<STDSRenderTarget>(mAutoSize.x, mAutoSize.y);
            fbo->bindSelf();
            if (inputFbo == nullptr) {
                break;
            }
            effect->setTexture(inputFbo->getTexture());
            effect->draw();
            fbo->restore();
            inputFbo = fbo;
        }
        
        if (inputFbo != nullptr) {
            drawTexture(inputFbo->getTexture());
        }
    }
    
    shared_ptr<STDSRenderTarget> drawShapen() {
        return nullptr;
    }
    
private:
    shared_ptr<STDSPath> mStrokePath{nullptr}; // 路径
    shared_ptr<STDSShapenStrokeEffect> mStrokeEffect{nullptr};// 描边绘制
    shared_ptr<STDSShapenFillEffect> mFillEffect{nullptr};// 填充绘制
    vec4 mFillColor; // 填充颜色
    vec4 mStrokeColor; // 描边颜色
    float mStrokeWidth; // 描边宽度
};
#endif /* STDShapenLayer_hpp */
